package game;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Observable;

/**
 * Score board of game
 * @author Natchanon Hongladaromp
 *
 */
public class ScoreBoard extends Observable
{
	List<ScoreItem> list;
	
	/**
	 * Construct for score board.
	 * @param mode game mode
	 */
	public ScoreBoard(GameMode mode)
	{
		list = new ArrayList<ScoreItem>();
	}
	
	/**
	 * Add new score.
	 * @param name player's name
	 * @param score player's score
	 */
	public void addScore(String name, double score)
	{
		list.add(new ScoreItem(name,score));
		Collections.sort(list);
		setChanged();
		notifyObservers(UpdateType.UPDATE_SCORE);
	}
	
	/**
	 * Resets score board.
	 */
	public void reset()
	{
		list = new ArrayList<ScoreItem>();
		setChanged();
		notifyObservers(UpdateType.UPDATE_SCORE);
	}
	
	/**
	 * Returns list of score item.
	 * @return list of score item
	 */
	public List<ScoreItem> getScore()
	{
		return list;
	}
}
